package com.wsoft.core.security;

import com.sun.javafx.binding.StringConstant;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 功能描述
 *
 * @author: juiet
 * @date: 2024年09月03日 22:05
 */
@Service
@RequiredArgsConstructor
public class LogoutHandler implements org.springframework.security.web.authentication.logout.LogoutHandler{
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        SecurityContextHolder.clearContext();
    }

    /**
     * 加入黑名单
     *
     * @param token 令牌
     */
    private void blacklist(String token) {
//        String jti = JwtUtil.getJti(token);
//        Long expires = JwtUtil.getExpires(token);
//        redisUtil.set("token:black:" + jti + ":string", StringConstant.EMPTY, DateUtil.minusSeconds(expires));
    }
}
